<template>
  <el-form inline>
    <el-form-item label="一级分类"> 
      <el-select v-model="categoryStore.category1Id" @change="categoryStore.getCategory2List">
        <el-option 
        v-for="c1 in categoryStore.category1List" 
        :key="c1.id" 
        :value="c1.id"
        :label="c1.name"
        />
      </el-select>
    </el-form-item>
    <el-form-item label="二级分类">
      <el-select v-model="categoryStore.category2Id" @change="categoryStore.getCategory3List">
        <el-option 
        v-for="c2 in categoryStore.category2List"
        :value="c2.id"
        :key="c2.id"
        :label="c2.name"
        />
      </el-select>
    </el-form-item>
    <el-form-item label="三级分类">
      <el-select v-model="categoryStore.category3Id">
        <el-option 
          v-for="c3 in categoryStore.category3List"
          :value="c3.id"
          :key="c3.id"
          :label="c3.name"
         />
      </el-select>
    </el-form-item>
  </el-form>
</template>

<script setup lang="ts">
// import useCategoryStore from '@/stores/category'
import useCategoryStore from '@/stores/category'
import { onMounted } from 'vue';
const categoryStore = useCategoryStore();
onMounted(() => {
  categoryStore.getCategory1List();
})
</script>

<style scoped></style>